package com.yztc.xiami_app.adapter.homepage;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * Created by 周旭 on 2016/11/15.
 * <p>
 * 广告的适配器
 */

public class ADAdapter extends PagerAdapter {

    private List<ImageView> mAdList;

    public ADAdapter(List<ImageView> mAdList) {
        this.mAdList = mAdList;
    }

    @Override
    public int getCount() {
        return mAdList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = mAdList.get(position);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        View view = mAdList.get(position);
        container.removeView(view);
    }
}
